package com.daluzy.chmanager.adapter;

import android.content.Context;
import android.content.Intent;
import android.text.TextUtils;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.recyclerview.widget.RecyclerView;

import com.daluzy.chmanager.R;
import com.daluzy.chmanager.bean.Employee;
import com.daluzy.chmanager.bean.Manager;

import java.util.ArrayList;
import java.util.List;

import butterknife.BindView;
import butterknife.ButterKnife;

public class EmployeeAdapter extends RecyclerView.Adapter<EmployeeAdapter.MyViewHolder> {



    private Context context;
    private List<Employee> myData = new ArrayList<>();

    public EmployeeAdapter(Context context, List<Employee> myData) {
        this.context = context;
        this.myData = myData;
    }

    @NonNull
    @Override
    public MyViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int viewType) {
        View view = LayoutInflater.from(context).inflate(R.layout.adapter_employee_item_daluzy, parent, false);
        return new MyViewHolder(view);
    }

    @Override
    public void onBindViewHolder(@NonNull MyViewHolder holder, int position) {
        Employee employee = myData.get(position);
        holder.tvEmployeeName.setText(String.format("姓名：%s", employee.getEmployee_name()));
        holder.tvEmployeePhone.setText(employee.getEmployee_phone());
       holder.tvEmployeeSex.setText(employee.getEmployee_sex());


    }

    @Override
    public int getItemCount() {
        return myData.size();
    }

    class MyViewHolder extends RecyclerView.ViewHolder {
        @BindView(R.id.tv_employee_name)
        TextView tvEmployeeName;
        @BindView(R.id.tv_employee_sex)
        TextView tvEmployeeSex;
        @BindView(R.id.tv_employee_phone)
        TextView tvEmployeePhone;

        public MyViewHolder(@NonNull View itemView) {
            super(itemView);
            ButterKnife.bind(this, itemView);
        }
    }
}
